<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ include file="/WEB-INF/views/include/head.jsp"%>
<%@ taglib uri="/WEB-INF/tlds/att.tld" prefix="att"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="${staticPath}/css/layout.css" type="text/css" rel="stylesheet" />

</head>
<body style="background-color: #fff;">
<script type="text/javascript">
	function Att_LoadFile(modleName,key,soureBillID){
		var downloadFileListURL = "${contextPath}/sys/att/attr/download/list?modleName="+modleName+"&key="+key+"&soureBillID="+soureBillID;
		$.ajax({
			url: downloadFileListURL,
			success:function(data){
				data = {o:eval("("+data+")")};
				data.o.formatFileSize = function(size){
        			return (size / 1000)+'KB';
        		};
				data.o.formatFileIcon = function(fileType){
					switch(fileType){
						case "application/msword":return "doc_1.png";
						case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":return "doc_1.png";
						case "application/vnd.ms-excel":return "xls_1.png";
						case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return "xls_1.png";
						case "application/vnd.ms-powerpoint":return "pdf_1.png";
						case "application/pdf":return "pdf_1.png";
						case "text/plain":return "text_1.png";
						case "application/x-jpg":return "img_1.png";
						case "application/x-ico":return "img_1.png";
						case "application/x-bmp":return "img_1.png";
						case "image/gif":return "img_1.png";
						case "image/png":return "img_1.png";
						case "image/jpeg":return "img_1.png";
						default:return "documents_1.png";
					}
        		};
				var html = template('file-view-tmp', data);
				$("#file-view-"+key).html(html);
			},
			failure:function(){
				alert('数据请求失败!请重试');
				window.close();
			}
		});
	}
</script>
<script id="file-view-tmp" type="text/html">
	{{each o.files as file}}
		  <tr>
               <td><span class="preview img_preview"><img src="${staticPath}/images/icon/fileIcon/{{o.formatFileIcon(file.fileType)}}" height="26" width="26"></span></td>
               <td><p class="name">{{file.name}}</p></td>
               <td><p class="size">{{o.formatFileSize(file.size)}}</p> </td>
               <td> 
					<a href="${contextPath}{{file.url}}" title="{{file.name}}">
                   <button type="submit" class="btn btn-warning img_padding_btn img_margin btn_3">
                       <i class="glyphicon glyphicon-download-alt"></i>
                       <span>&nbsp;下&nbsp;载</span>
                   </button>
					</a>
                </td>
           </tr>
	{{/each}}
</script>
<div class="bs-example" name="ossp-attachment-contr">
    <table role="presentation" class="img_table padding">
       <tbody id="file-view-janathan">
       </tbody>
   </table>
   <script type="text/javascript">
		$(document).ready(function (){
			Att_LoadFile("2","janathan","1");
		});
	</script>
</div>
</body>
</html>